﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web.UI.WebControls;
using eCommerce.BusinessLogic;
using eCommerce.DataAccess;

namespace eCommerce.Site
{
    public partial class Search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = Request.QueryString["s"];
            if (str != null)
            {
                //var searchResult = SearchBL.SearchProducts(str);
                //int i = -1;
                SiteProductsDataContext siteProductsDataContext = new SiteProductsDataContext();
                
                        var posts = from sq in siteProductsDataContext.Products
                                    orderby sq.ProductName descending
                                    where sq.ProductName.Contains(str) || sq.ProductDesc.Contains(str) 
                                    select new{sq.ProductID,sq.ProductName};

               // gridView.DataSource = searchResult[];
                gridView.DataSource = posts;
                gridView.DataBind();
            }

           
        }
        protected void GridPageIndexChanging(object source, GridViewPageEventArgs e)
        {
        }
    }
}
